<template>
  <div :class="[`nav-theme-${navTheme}`, `nav-layout-${navLayout}`]">
    <a-layout style="height: 100vh">
      <a-layout-sider
        v-if="navLayout === 'left'"
        :theme="navTheme"
        :trigger="null"
        v-model="collapsed"
        collapsible
        width="256px"
        :style="`background: url(${require('@/assets/sider-bg.png')}) no-repeat left bottom, #fff;background-size: contain;overflow-x:hidden`"
      >
        <div class="logo">商超数据信息采集平台</div>
        <SiderMenu :theme="navTheme" />
        <a-icon
          v-auth="['admin']"
          :type="collapsed ? 'menu-unfold' : 'menu-fold'"
          @click="collapsed = !collapsed"
          class="trigger"
        />
      </a-layout-sider>
      <a-layout class="layout-box">
        <a-layout-header
          :style="{
            position: 'fixed',
            width: collapsed ? 'calc(100% - 80px)' : 'calc(100% - 256px)',
            background: '#ffffff',
            padding: 0,
            height: '48px',
            zIndex: 999,
            transition: 'all 0.2s',
          }"
        >
          <Header>
            <a-breadcrumb style="margin: 16px 0">
              <a-breadcrumb-item v-for="(item, index) in routea" :key="index"
                ><router-link :to="item.path">{{
                  item.title
                }}</router-link></a-breadcrumb-item
              >
            </a-breadcrumb>
          </Header>
        </a-layout-header>
        <a-layout-content
          style="
            margin: 62px 10px 0;
            padding: 16px;
            min-height: unset;
            box-sizing: border-box;
            background: #fff;
          "
        >
          <router-view />
        </a-layout-content>
        <a-layout-footer v-if="false" style="text-align: center">
          <Footer />
        </a-layout-footer>
      </a-layout>
    </a-layout>
    <Authorized :authority="['admin']">
      <SettingDrawer />
    </Authorized>
  </div>
</template>

<script>
import Header from "./Header";
import Footer from "./Footer";
import SiderMenu from "./SiderMenu";
import SettingDrawer from "@/components/SettingDrawer";
export default {
  components: {
    Header,
    Footer,
    SiderMenu,
    SettingDrawer,
  },
  data() {
    return {
      collapsed: false,
    };
  },
  computed: {
    navTheme() {
      return this.$route.query.navTheme || "light";
    },
    navLayout() {
      return this.$route.query.navLayout || "left";
    },
    routea() {
      return this.$store.state.user.routea;
    },
  },
  created() {
    this.$store.dispatch("user/Breadcrumb", this.$route.matched);
  },
};
</script>

<style scoped lang="less">
.trigger {
  position: fixed;
  bottom: 16px;
  left: 16px;
  padding: 10px;
  font-size: 20px;
}
.trigger:hover {
  background: #eeeeee;
}
.nav-theme-dark .logo {
  color: #fff;
}
.logo {
  height: 48px;
  line-height: 48px;
  text-align: center;
  user-select: none;
  font-family: "TsangerYuYangT";
  cursor: pointer;
  letter-spacing: 1px;
  overflow: hidden;
  font-size: 20px;
  color: @primary-color;
}
</style>
<style lang="less">
.layout-box {
  background: #eff4fb;
}
</style>
